﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;

public partial class cn_XML_result : System.Web.UI.Page
{
    VotesKeyWordsBLL vkwBll = null;
    IList<VotesKeyWordsModel> vkwList = null;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            string codestr = Request.Form["code"].ToString();
            if (codestr != null)
            {
                GetData(Convert.ToInt32(codestr));
            }
            
        }
    }
    private void GetData(int code)
    {
        vkwBll = new VotesKeyWordsBLL(code);
        vkwList = vkwBll.selectKeyWordsNrelsy();
        StringBuilder lastHtml = new StringBuilder();
        double totals = 0;
        foreach (VotesKeyWordsModel vkw in vkwList)
        {
            totals +=Convert.ToInt32( vkw.Count);
        }
        foreach (VotesKeyWordsModel vkw in vkwList)
        {
            if (vkw.Count!=null)
            {
                lastHtml.AppendFormat("{0}(<span style='color:#8B8378'>{1}%,{2}{3}</span>)|", vkw.Name, ((vkw.Count / totals) * 100).ToString().Substring(0, 5), vkw.Count,(Request.Form["code"]=="1033"?"Votes":"票"));
            }
            
        }
        string lsh = lastHtml.ToString();
        lsh = lsh.Remove(lsh.LastIndexOf('|'), 1);
        if (lsh != "" && lsh != null)
        {
            Response.Write(lsh);
        }
        else
        {
            
            Response.Write("0");
        }

       
    }
}